<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ showList.length }}</strong></span
    >
    <ul class="filters" @click="getIsSel">
      <li>
        <a
          :class="{ selected: isSelected == 'all' }"
          href="javascript:;"
          @click="isSelected = 'all'"
          >全部</a
        >
      </li>
      <li>
        <a
          @click="isSelected = 'no'"
          href="javascript:;"
          :class="{ selected: isSelected == 'no' }"
          >未完成</a
        >
      </li>
      <li>
        <a
          @click="isSelected = 'yes'"
          href="javascript:;"
          :class="{ selected: isSelected == 'yes' }"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clear">清除已完成</button>
  </footer>
</template>

<script>
import { mapMutations, mapGetters } from "vuex";
export default {
  data() {
    return {
      isSelected: "all",
    };
  },
  computed: {
    ...mapGetters(["showList"]),
  },
  methods: {
    ...mapMutations(["filterList", "clearDone"]),
    getIsSel() {
      // this.$emit("filterList", this.isSelected);
      this.filterList(this.isSelected);
    },
    clear() {
      // this.$emit("clearDone");
      this.clearDone();
    },
  },
};
</script>
